package com.aaa.controller;

import com.aaa.entity.Role;
import com.aaa.entity.Roomtype;
import com.aaa.service.RoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Role)表控制层
 *
 * @author makejava
 * @since 2022-01-12 13:27:05
 */
@RestController
@RequestMapping("role")
public class RoleController {
    /**
     * 服务对象
     */
    @Resource
    private RoleService roleService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Role selectOne(Integer id) {
        return this.roleService.queryById(id);
    }

//    添加角色
    @RequestMapping("saveRole")
    public Object SaveRole(Role role){
        Role role1=roleService.insert(role);
        return role1;
    }

//    查看角色信息
    @RequestMapping("selectRole")
    public List<Role> SelectRole(Integer pageNum,Integer pageSize){
        List<Role> RoleList=roleService.queryAllByLimit(pageNum,pageSize);
        System.out.println(RoleList);
        return RoleList;
    }

//    修改角色
    @RequestMapping("updateRole")
    public Object UpdateRole(Role role){
        Role state=roleService.update(role);
        return state;
    }
//    删除角色
    @RequestMapping("deleteRoleByid")
    public Object deleteRoleByid(Integer id){
        Boolean state=roleService.deleteById(id);
        return state;
    }
}